// *** ADDED BY HEADER FIXUP ***
#include <wx/utils.h>
// *** END ***
#include "wx_pch.h"
#include "KeyHLPanel.h"

#ifndef WX_PRECOMP
//(*InternalHeadersPCH(KeyHLPanel)
#include <wx/intl.h>
#include <wx/string.h>
//*)
#endif
//(*InternalHeaders(KeyHLPanel)
#include <wx/font.h>
//*)

//(*IdInit(KeyHLPanel)
const long KeyHLPanel::ID_STATICTEXT2 = wxNewId();
const long KeyHLPanel::ID_TEXTCTRL1 = wxNewId();
const long KeyHLPanel::ID_STATICTEXT1 = wxNewId();
const long KeyHLPanel::ID_BUTTON3 = wxNewId();
const long KeyHLPanel::ID_STATICTEXT3 = wxNewId();
const long KeyHLPanel::ID_BUTTON1 = wxNewId();
const long KeyHLPanel::ID_STATICTEXT4 = wxNewId();
const long KeyHLPanel::ID_BUTTON2 = wxNewId();
//*)

BEGIN_EVENT_TABLE(KeyHLPanel,wxPanel)
    //(*EventTable(KeyHLPanel)
    //*)
END_EVENT_TABLE()

KeyHLPanel::KeyHLPanel(wxWindow* parent,wxString name,wxColour textC,wxColour textBgC,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
    //(*Initialize(KeyHLPanel)
    wxBoxSizer* BoxSizer1;

    Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL, _T("wxID_ANY"));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    StaticText2 = new wxStaticText(this, ID_STATICTEXT2, wxT("角色"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT, _T("ID_STATICTEXT2"));
    BoxSizer1->Add(StaticText2, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
    RoleName = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(82,22), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    BoxSizer1->Add(RoleName, 2, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
    StaticText1 = new wxStaticText(this, ID_STATICTEXT1, wxT("文字"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT, _T("ID_STATICTEXT1"));
    BoxSizer1->Add(StaticText1, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
    BnTextColor = new wxButton(this, ID_BUTTON3, wxEmptyString, wxDefaultPosition, wxSize(24,24), 0, wxDefaultValidator, _T("ID_BUTTON3"));
    BoxSizer1->Add(BnTextColor, 0, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
    StaticText3 = new wxStaticText(this, ID_STATICTEXT3, wxT("背色"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT, _T("ID_STATICTEXT3"));
    BoxSizer1->Add(StaticText3, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
    BnTextBgColour = new wxButton(this, ID_BUTTON1, wxEmptyString, wxDefaultPosition, wxSize(24,24), 0, wxDefaultValidator, _T("ID_BUTTON1"));
    BoxSizer1->Add(BnTextBgColour, 0, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
    SampleText = new wxStaticText(this, ID_STATICTEXT4, wxT("样例"), wxDefaultPosition, wxSize(100,14), 0, _T("ID_STATICTEXT4"));
    wxFont SampleTextFont(10,wxSWISS,wxFONTSTYLE_NORMAL,wxBOLD,false,wxEmptyString,wxFONTENCODING_DEFAULT);
    SampleText->SetFont(SampleTextFont);
    BoxSizer1->Add(SampleText, 3, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
    BnClose = new wxButton(this, ID_BUTTON2, wxT("×"), wxDefaultPosition, wxSize(18,18), 0, wxDefaultValidator, _T("ID_BUTTON2"));
    BnClose->SetId(wxNewId());
    BoxSizer1->Add(BnClose, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
    SetSizer(BoxSizer1);
    TextColourDlg = new wxColourDialog(this);
    TextBgColourDlg = new wxColourDialog(this);
    BoxSizer1->Fit(this);
    BoxSizer1->SetSizeHints(this);

    Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&KeyHLPanel::OnBnTextColorClick);
    Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&KeyHLPanel::OnBnTextBgColourClick);
    Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&KeyHLPanel::OnButton2Click);
    Connect(wxEVT_PAINT,(wxObjectEventFunction)&KeyHLPanel::OnPaint);
    //*)
    SetRoleName(name);
    SetTextColour(textC);
    SetTextBgColour(textBgC);
}

KeyHLPanel::~KeyHLPanel()
{
    //(*Destroy(KeyHLPanel)
    //*)
}


void KeyHLPanel::OnPaint(wxPaintEvent& event)
{
    //wxMessageBox(wxT("New Button creat!"));
    //Button1->Show();
    event.Skip();
}

void KeyHLPanel::OnTextCtrl1Text(wxCommandEvent& event)
{
}

void KeyHLPanel::OnButton2Click(wxCommandEvent& event)
{
    event.Skip();
}

void KeyHLPanel::OnBnTextColorClick(wxCommandEvent& event)
{
    if(TextColourDlg->ShowModal()==wxID_OK)
    {
        SetTextColour(TextColourDlg->GetColourData().GetColour());
        Refresh();
    }
}
void KeyHLPanel::SetRoleName(wxString s)
{
    RoleName->SetValue(s);
}

void KeyHLPanel::SetTextColour(wxColour c)
{
    BnTextColor->SetBackgroundColour(c);
    TextColourDlg->GetColourData().SetColour(c);
    SampleText->SetForegroundColour(c);
}

void KeyHLPanel::SetTextBgColour(wxColour c)
{
    BnTextBgColour->SetBackgroundColour(c);
    TextBgColourDlg->GetColourData().SetColour(c);
    SampleText->SetBackgroundColour(c);
}
wxColour KeyHLPanel::GetTextBgColour()
{
    return SampleText->GetBackgroundColour();
}

wxColour KeyHLPanel::GetTextColour()
{
    return SampleText->GetForegroundColour();
}

wxString KeyHLPanel::GetRoleName()
{
    return RoleName->GetValue();
}

int KeyHLPanel::GetId()
{
    return BnClose->GetId();
}

void KeyHLPanel::OnBnTextBgColourClick(wxCommandEvent& event)
{
    if(TextBgColourDlg->ShowModal()==wxID_OK)
    {
        SetTextBgColour(TextBgColourDlg->GetColourData().GetColour());
        Refresh();
    }
}
